<?php
	$result = 0;
	 
	$target_path = "../users/" . $_REQUEST["user_name"] ."/". basename( $_FILES['myfile']['name']);
	 
	if(@move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path)) {
		echo 1;
	}
	else
		echo 0;
	 
	sleep(1);
	
	require_once('../class/NguoiDungDAO.php');
	require_once('../session.inc');
	
	$nguoiDungDto = NguoiDungDAO::LayThongTinNguoiDungTheoMa($_SESSION['IdUser']);
	
	NguoiDungDAO::CapNhatAvatarNguoiDung("users/" . $_REQUEST["user_name"] ."/". basename( $_FILES['myfile']['name']), $nguoiDungDto->MaNguoiDung);
?>